﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace iLangl.Customer.DAL.XMLStorage
{
	public class XMLStorageConfiguration : ConfigurationSection
	{
		private static ConfigurationProperty filePathToStorageProperty;
		
		private static XMLStorageConfiguration instance;
		private static ConfigurationPropertyCollection properties;

		static XMLStorageConfiguration()
		{
			filePathToStorageProperty = new ConfigurationProperty(
			  "filePathToStorageProperty",
			  typeof(String),
			  null,
			  ConfigurationPropertyOptions.IsRequired);

			
			properties = new ConfigurationPropertyCollection();
			properties.Add(filePathToStorageProperty);
			
		}

		private static object mutex = new object();
		/// <summary>
		/// The instance of the TransportConfiguration.
		/// </summary>
		public static XMLStorageConfiguration Instance
		{
			get
			{
				if (instance == null)
				{
					lock (mutex)
					{
						if (instance == null)
						{
							instance = ConfigurationManager.GetSection("XMLStorageConfiguration") as XMLStorageConfiguration;
						}
					}
				}
				return instance;
			}
		}

		/// <summary>
		/// Path to the file of xml storage.
		/// </summary>
		public String FilePathToStorage
		{
			get
			{
				return base[filePathToStorageProperty] as String;
			}
		}

		protected override ConfigurationPropertyCollection Properties
		{
			get
			{
				return properties;
			}
		}
	}
}